<?php
class Silk_Zgb_Block_Adminhtml_Dealer_Edit_Tab_Form extends Mage_Adminhtml_Block_Widget_Form
{
		protected function _prepareForm()
		{

				$form = new Varien_Data_Form();
				$this->setForm($form);

				$dealer = Mage::registry("dealer_data");

				$fieldset = $form->addFieldset("zgb_form", array("legend"=>Mage::helper("zgb")->__("经销商信息")));

				
						$fieldset->addField("name", "text", array(
						"label" => Mage::helper("zgb")->__("名称"),					
						"class" => "required-entry",
						"required" => true,
						"name" => "name",
						));
					
						$fieldset->addField("contact_name", "text", array(
						"label" => Mage::helper("zgb")->__("联系人"),					
						"class" => "required-entry",
						"required" => true,
						"name" => "contact_name",
						));
					
						$fieldset->addField("contact_phone", "text", array(
						"label" => Mage::helper("zgb")->__("联系电话"),					
						"class" => "required-entry",
						"required" => true,
						"name" => "contact_phone",
						));
					
						$fieldset->addField("contact_address", "text", array(
						"label" => Mage::helper("zgb")->__("联系地址"),					
						"class" => "required-entry",
						"required" => true,
						"name" => "contact_address",
						));

						// $fieldset->addField(
			   //              'website_id',
			   //              'select',
			   //              array(
			   //                   'name'     => 'website_id',
			   //                   'label'    => Mage::helper('cms')->__('销售区域'),
			   //                   'title'    => Mage::helper('cms')->__('销售区域'),
			   //                   'required' => true,
			   //                   'values'   => Mage::getSingleton('adminhtml/system_store')->getWebsiteValuesForForm(false, true),
			   //              )
			   //          );
					
						$fieldset->addField("note", "textarea", array(
						"label" => Mage::helper("zgb")->__("备注"),
						"name" => "note",
						));
					
				$fieldset = $form->addFieldset("zgb_login_form", array("legend"=>Mage::helper("zgb")->__("登录信息")));
				
						$fieldset->addField("login_name", "text", array(
						"label" => Mage::helper("zgb")->__("登录帐号"),					
						"class" => "required-entry",
						"required" => true,
						"name" => "login_name",
						));

						if(!$dealer->getId())
						{
							$fieldset->addField("password", "password", array(
							"label" => Mage::helper("zgb")->__("密码"),					
							"class" => "required-entry validate-admin-password",
							"required" => true,
							"name" => "password",
							));
						}
				$fieldset = $form->addFieldset("zgb_registered_form", array("legend"=>Mage::helper("zgb")->__("工商信息")));		
					
						$fieldset->addField("address", "text", array(
						"label" => Mage::helper("zgb")->__("注册地址"),
						"name" => "address",
						));
					
						$fieldset->addField("registered_capital", "text", array(
						"label" => Mage::helper("zgb")->__("注册资本"),
						"name" => "registered_capital",
						));
					
						$fieldset->addField("registered_no", "text", array(
						"label" => Mage::helper("zgb")->__("注册号"),
						"name" => "registered_no",
						));
					
						$fieldset->addField("registered_date", "text", array(
						"label" => Mage::helper("zgb")->__("注册日期"),
						"name" => "registered_date",
						));
					
						$fieldset->addField("registration_authority", "text", array(
						"label" => Mage::helper("zgb")->__("登记机关"),
						"name" => "registration_authority",
						));
					
						$fieldset->addField("business_type", "text", array(
						"label" => Mage::helper("zgb")->__("企业类型"),
						"name" => "business_type",
						));
					
						$fieldset->addField("business_entity", "text", array(
						"label" => Mage::helper("zgb")->__("法定代表人"),
						"name" => "business_entity",
						));
					
						$fieldset->addField("business_scope", "text", array(
						"label" => Mage::helper("zgb")->__("经营范围"),
						"name" => "business_scope",
						));
					
						$fieldset->addField("business_term", "text", array(
						"label" => Mage::helper("zgb")->__("营业期限"),
						"name" => "business_term",
						));
					
						$fieldset->addField("product_services", "textarea", array(
						"label" => Mage::helper("zgb")->__("主营产品或服务"),
						"name" => "product_services",
						));


				if (Mage::getSingleton("adminhtml/session")->getDealerData())
				{
					$form->setValues(Mage::getSingleton("adminhtml/session")->getDealerData());
					Mage::getSingleton("adminhtml/session")->setDealerData(null);
				} 
				elseif(Mage::registry("dealer_data")) {
				    $form->setValues(Mage::registry("dealer_data")->getData());
				}
				return parent::_prepareForm();
		}
}
